<%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
<%@ page import="exam.AnswerPaperInfo" %>
<%@ page import="utils.TextUtils" %>
<%@ page import="question.QuestionVar" %>
<%@ page import="java.util.List" %>
<%@ page import="question.QuestionUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
  int index = (Integer) vs.findValue("index");
  int sum = (Integer) vs.findValue("sum");
  List<AnswerPaperInfo> alist = (List<AnswerPaperInfo>) vs.findValue("alist");
  AnswerPaperInfo ainfo = (AnswerPaperInfo) vs.findValue("ainfo");

  String done = "";
  for (int i = 0; i < alist.size(); i++) {
    AnswerPaperInfo info = alist.get(i);
    if (info.getAnswer() != null && info.getAnswer().length() != 0) {
      done += (done.length() == 0 ? "" : ",") + (i + 1);
    }
  }
%>
<form action="fillAnswer.action" method="post" id="examform" target="submitframe">
  <input name="to" type="hidden" id="answergoto"/>
  <input name="index" id="indexinput" type="hidden" value="<%=index%>"/>
  <input name="answer" type="hidden" id="answerinput"/>
  <div class="subPanel">
    <h1>第<font style="color:#A20000"><%=index%></font>题 <b><%=QuestionUtils.getTx(ainfo.getTx())%>题</b><strong>【总共<%=sum%>题】</strong><span></span>

      <strong class="answer" id="answer">[]</strong></h1>

    <div class="overflow">
      <%=TextUtils.html(ainfo.getContent())%>

      <div class="subBar" id="subBar">
        <%
          if (ainfo.getTx() == QuestionVar.TX_TF) {
        %>
        <span UNSELECTABLE="on" id="exam1" onClick="EXAM.setAnswer('1')" value="√" class="exam1"></span>
        <span UNSELECTABLE="on" id="exam2" onClick="EXAM.setAnswer('2')" value="×" class="exam2"></span>
        <%
        }
        else {
        %>
        <span UNSELECTABLE="on" id="examA" onClick="EXAM.setAnswer('A')" value="A" class="examA"></span>
        <span UNSELECTABLE="on" id="examB" onClick="EXAM.setAnswer('B')" value="B" class="examB"></span>
        <span UNSELECTABLE="on" id="examC" onClick="EXAM.setAnswer('C')" value="C" class="examC"></span>
        <%
          }
        %>


      </div>
    </div>
    <div class="subNav">
      <%
        if (index > 1) {
      %>
      <input type="button" id="pr" avalue="<%=index-1%>" onClick="EXAM.gotoExam('<%=index-1%>')" class="pr"/>
      <%
        }
        if (index != sum) {
      %>
      <input type="button" id="ne" avalue="<%=index+1%>" onClick="EXAM.gotoExam('<%=index+1%>')" class="ne"/>
      <%
        }
       if (index == sum){
      %>
      <!--<input type="button" id="ne" avalue="<%=index+1%>" onClick="EXAM.gotoExam('<%=index+1%>')" class="sa"/>-->
      <%
       }
      %>
      <span type="button" id="re" UNSELECTABLE="on" onClick="EXAM.rewriteAnswer()" class="re"></span>
    </div>
  </div>
</form>
<script>
  // 1判断 2单选 3多选
  EXAM.setExamType(<%=ainfo.getTx()%>)

  //查看题目的时候加答案 R F A B C
<%
  if(ainfo.getAnswer()!=null&&ainfo.getAnswer().trim().length()!=0){
%>
  
  EXAM.loadAnswer("<%=ainfo.getAnswer()%>")
<%
  }
%>
  //加亮已经做题,如果已做，但是选择重做，又没有选择答案，不应该加亮
  EXAM.highLightOld([<%=done%>])

  //加亮正在做的这一题
  EXAM.highLightThis("<%=index%>")

</script>